package com.example.ajaxdemo.fastjson;


import java.util.List;

/**
 * @description: 统一的应答结果类
 * @author: uu
 * @data: 2023/7/11 下午 07:15
 * @version: v1.0
 */

public class RespResult {
    /*应答码*/
    private int code;
    /*code的文字说明，一般作为提示*/
    private String msg;
    /*访问token*/
    private String accessToken;
    /*单个数据*/
    private Object data;
    /*集合数据*/
    private List list;
    /*分页*/

    // 表示成功的RespResult对象
    public static RespResult success(){
        RespResult result = new RespResult();
        result.setRCode(RCode.SUCC);
        return result;
    }
    // 表示失败|默认
    public static RespResult fail(){
        RespResult result = new RespResult();
        result.setRCode(RCode.UNKOWN);
        return result;
    }

    public void setRCode(RCode code){
        this.code = code.getCode();
        this.msg = code.getText();
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public String getAccessToken() {
        return accessToken;
    }

    public void setAccessToken(String accessToken) {
        this.accessToken = accessToken;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public List getList() {
        return list;
    }

    public void setList(List list) {
        this.list = list;
    }
}
